package com.huadi.ssm.Controller;

import com.huadi.ssm.Service.EvidenceService;
import com.huadi.ssm.po.Evidence;
import com.huadi.ssm.po.User;
import com.oracle.jrockit.jfr.EventDefinition;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;
import java.util.List;

@Controller
@RequestMapping("/evidence")
public class EvidenceController {

    @Autowired
    @Qualifier("EvidenceServiceImpl")
    private EvidenceService evidenceService;

    //1:中心人员获取所有的物证
    @RequestMapping("/allevidence")
    public String selectAllEvidence(Model model, HttpSession session){
        User user=(User)session.getAttribute("user");
        if(user.getUserdepartment().equals("中心部门")){
        List<Evidence> evidences= evidenceService.findAllEvidence();
        model.addAttribute("evidence",evidences );}
        else{
            List<Evidence>evidences=evidenceService.FireFindAllEvi(user.getUserId());
            model.addAttribute("evidence",evidences );
        }

        return "allEvidence";
    }

    //：技术人员获取所有物证
    @RequestMapping("/TechnicianGetEvi")
    public String TechnicianGetEvidence(Model model){
        List<Evidence> evidences= evidenceService.findAllEvidence();
        model.addAttribute("evidence",evidences );
        return "eviForTec";}

//    //2：进入到添加物证界面
//    @RequestMapping("/toaddEvidence")
//    public String toaddEvidence(){return "addEvidence";}

//    //3:进行物证添加操作
//    @RequestMapping("/addEvidence")
//    public String addEvidence(Evidence evidence){
//        evidenceService.addEvidence(evidence);
//        return "redirect:/evidence/allevidence";
//    }
//
//    //4：删除物证
//    @RequestMapping("/deleteEvidence")
//    public String deleteEvidence(String evidenceId){
//        evidenceService.deleteEvidenceById(evidenceId);
//        return "redirect:/evidence/allevidence";
//    }
//
//    //5：进入物证修改页面
//    @RequestMapping("/toupdateEvidence")
//    public String toupdateEvidence( ){
//        return "";//转到物证修改的页面
//
//    }
//
//    //6：进行修改物证操作
//    @RequestMapping("/updateEvidence")
//    public String updateEvidence(Evidence evidence){
//        evidenceService.updateEvidenceve(evidence);
//        return "redirect:/evidence/allevidence";
//    }

    //7:查找单个物证
    @RequestMapping("/selectEvidence")
    public String selectOneEvidence(String evidenceId) {
        Evidence evidence = evidenceService.findEvidenceByUserId(evidenceId);
        if (null == evidence) {//返回查找页面并告知不存在，重新输入）
            return null;
        } else {
            //高亮显示被找到的物证
            return null;
        }
    }



}
